from sahi.slicing import slice_coco


coco_dict, coco_path = slice_coco(
    coco_annotation_file_path="ann.json",
    image_dir="images/",
    output_coco_annotation_file_name="sliced_coco.json",
    ignore_negative_samples=False,
    output_dir="sliced/",
    slice_height=640,
    slice_width=640,
    overlap_height_ratio=0.2,
    overlap_width_ratio=0.2,
    min_area_ratio=0.1,
    verbose=True
)

get_ipython().system('sahi coco yolov5 --image_dir sliced --dataset_json_path sliced/sliced_coco.json')
get_ipython().system('mkdir -p dataset_sliced/labels/train/ dataset_sliced/images/train/')
get_ipython().system('mv runs/coco2yolov5/exp/train/*.txt dataset_sliced/labels/train/')
get_ipython().system('mv runs/coco2yolov5/exp/train/*.jpg dataset_sliced/images/train/')
# get_ipython().system('zip -r -q dataset_sliced.zip dataset_sliced')

